package cn.xutongxue.gtms.base;

import cn.hutool.core.util.ObjectUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * @author XuTongXue
 * @version 1.0
 * @date 2022/12/12 18:37
 * @Description Result类
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {

    private int code;

    private String msg;

    private Object data;


    public static Result success(Object data) {
        return new Result(200, "success", data);
    }

    public static Result success(String msg) { return new Result(200, msg, null); }

    public static Result success(String msg, Object data) { return new Result(200, msg, data); }

    public static Result fail(int code, String msg) {
        return new Result(code, msg, null);
    }

    public static Result fail(Errors errors) {
        return new Result(errors.getCode(), errors.getMessage(), null);
    }

    public static Result fail(Errors errors, String message) {
        return new Result(errors.getCode(), message, null);
    }

}
